package com.hk.utils;

import org.lionsoul.ip2region.xdb.Searcher;

public class IpLocationUtil {
    public static String getLocation(String ip) {
        try {
            // 加载xdb数据库（需提前下载）
            String dbPath = "/path/to/ip2region.xdb";
            Searcher searcher = Searcher.newWithFileOnly(dbPath);
            String region = searcher.search(ip);
            return region; // 格式：国家|区域|省份|城市|ISP
        } catch (Exception e) {
            return "未知位置";
        }
    }
}